<?php
include('../config.php');
include(PUNG_ROOT . '/admin/header.php');
include(PUNG_ROOT . '/admin/config_manager.php');

$adminmenu = array(
LANG_047 => 'settings.php'
);

if(isset($_POST['submit']))
{
	$values = array(
	array('PAGETITLE', addslashes($_POST['pagetitle'])),
	array('SITENAME', addslashes($_POST['sitename'])),
	array('SLOGAN', addslashes($_POST['slogan'])),
	array('FOOTER', addslashes($_POST['footer'])),
	array('DESCRIPTION', addslashes($_POST['description'])),
	array('KEYWORDS', addslashes($_POST['keywords'])),
	array('ENCODING', $_POST['encoding']),
	array('ADMIN_TIPS', $_POST['tips']),
	array('PHPCONSOLE', $_POST['console']),
	array('DEBUG_MODE', $_POST['debugmode']),
	array('MODULE', $_POST['module']),
	array('PUNG_ROOT', $_POST['PUNG_root']),
	array('PUNG_URL', $_POST['PUNG_url']),
	array('LANGUAGE', $_POST['language'])
	);
	
	open_config_file();
	write_config_file($values);
	close_config_file();
	
	redirect_with_message('msg', 'LANG_075');
}

include(PUNG_ROOT . '/admin/head.php');
?>

<h3><?php print LANG_047; ?></h3>

<form action="" method="post">
<table width="100%">
<tr>
	<td width="190"><strong><?php print LANG_048; ?></strong></td>
	<td><input type="text" style="width: 250px" name="pagetitle" value="<?php print PAGETITLE; ?>" /></td>
</tr>
<tr>
	<td colspan="2" style="font-size:10px"><?php print LANG_061; ?></td>
</tr>
<tr>
	<td width="190"><strong><?php print LANG_049; ?></strong></td>
	<td><input type="text" style="width: 250px" name="sitename" value="<?php print SITENAME; ?>" /></td>
</tr>
<tr>
	<td colspan="2" style="font-size:10px"><?php print LANG_062; ?></td>
</tr>
<tr>
	<td width="190"><strong><?php print LANG_050; ?></strong></td>
	<td><input type="text" style="width: 250px" name="slogan" value="<?php print SLOGAN; ?>" /></td>
</tr>
<tr>
	<td colspan="2" style="font-size:10px"><?php print LANG_063; ?></td>
</tr>
<tr>
	<td width="190"><strong><?php print LANG_051; ?></strong></td>
	<td><input type="text" style="width: 250px" name="footer" value="<?php print FOOTER; ?>" /></td>
</tr>
<tr>
	<td colspan="2" style="font-size:10px"><?php print LANG_064; ?></td>
</tr>
<tr>
	<td width="190"><strong><?php print LANG_053; ?></strong></td>
	<td><input type="text" style="width: 250px" name="description" value="<?php print DESCRIPTION; ?>" /></td>
</tr>
<tr>
	<td colspan="2" style="font-size:10px"><?php print LANG_065; ?></td>
</tr>
<tr>
	<td width="190"><strong><?php print LANG_054; ?></strong></td>
	<td><input type="text" style="width: 250px" name="keywords" value="<?php print KEYWORDS; ?>" /></td>
</tr>
<tr>
	<td colspan="2" style="font-size:10px"><?php print LANG_066; ?></td>
</tr>
<tr>
	<td width="190"><strong><?php print LANG_052; ?></strong></td>
	<td><input type="text" style="width: 250px" name="encoding" value="<?php print ENCODING; ?>" /></td>
</tr>
<tr>
	<td colspan="2" style="font-size:10px"><?php print LANG_067; ?></td>
</tr>
<!--<tr>
	<td width="190"><strong><?php print LANG_055; ?></strong></td>
	<td>
	<input type="radio" value="on" name="tips"<?php if(ADMIN_TIPS == 'on'){print ' checked="checked"';} ?> /> On
	<input type="radio" value="off" name="tips"<?php if(ADMIN_TIPS == 'off'){print ' checked="checked"';} ?> /> Off
	</td>
</tr>
<tr>
	<td colspan="2" style="font-size:10px"><?php print LANG_068; ?></td>
</tr>-->
<tr>
	<td width="190"><strong><?php print LANG_056; ?></strong></td>
	<td>
	<input type="radio" value="on" name="console"<?php if(PHPCONSOLE == 'on'){print ' checked="checked"';} ?> /> On
	<input type="radio" value="off" name="console"<?php if(PHPCONSOLE == 'off'){print ' checked="checked"';} ?> /> Off
	</td>
</tr>
<tr>
	<td colspan="2" style="font-size:10px"><?php print LANG_069; ?></td>
</tr>
<tr>
	<td width="190"><strong><?php print LANG_057; ?></strong></td>
	<td>
	<input type="radio" value="on" name="debugmode"<?php if(DEBUG_MODE == 'on'){print ' checked="checked"';} ?> /> On
	<input type="radio" value="off" name="debugmode"<?php if(DEBUG_MODE == 'off'){print ' checked="checked"';} ?> /> Off
	</td>
</tr>
<tr>
	<td colspan="2" style="font-size:10px"><?php print LANG_070; ?></td>
</tr>
<tr>
	<td width="190"><strong><?php print LANG_058; ?></strong></td>
	<td>
	<?php
	$sql = $db -> db_query("SELECT * FROM " . DB_PREFIX . "modules ORDER BY date ASC");
	$sql = $db -> db_result();
	
	print '<select name="module" style="width:250px">';
	print '<option value="none"';
	if(MODULE == 'none')
	{
		print ' selected ="selected"';
	}
	print '>None</option>';
	foreach($sql as $module)
	{
		if($module['folder'] == MODULE)
		{
			print '<option value="' . $module['folder'] . '" selected="selected">' . $module['name'] . '</option>';
		}
		else
		{
			print '<option value="' . $module['folder'] . '">' . $module['name'] . '</option>';
		}
	}
	print '</select>';
	?>
	</td>
</tr>
<tr>
	<td colspan="2" style="font-size:10px"><?php print LANG_071; ?></td>
</tr>
<tr>
	<td width="190"><strong><?php print LANG_122; ?></strong></td>
	<td>
	<?php
	$dir = PUNG_ROOT . '/language/';
	$dh = opendir($dir);
	$files = array();
	
	while(false !== ($filename = readdir($dh)))
	{
		$files[] = $filename;
	}

	unset($files['0']);
	unset($files['1']);
	sort($files);
	
	print '<select name="language" style="width:250px">';
	foreach($files as $language)
	{
		$language = explode('.', $language);
		$language = $language['0'];
		
		print '<option value="' . $language . '"';
		if(LANGUAGE == $language)
		{
			print ' selected="selected"';
		}
		print '>' . ucfirst($language) . '</option>'; 
	}
	print '</select>';
	?>
	</td>
</tr>
<tr>
	<td colspan="2" style="font-size:10px"><?php print LANG_123; ?></td>
</tr>
<tr>
	<td width="190"><strong><?php print LANG_059; ?></strong></td>
	<td><input type="text" style="width: 250px" name="PUNG_root" value="<?php print PUNG_ROOT; ?>" /></td>
</tr>
<tr>
	<td colspan="2" style="font-size:10px"><?php print LANG_072; ?></td>
</tr>
<tr>
	<td width="190"><strong><?php print LANG_060; ?></strong></td>
	<td><input type="text" style="width: 250px" name="PUNG_url" value="<?php print PUNG_URL; ?>" /></td>
</tr>
<tr>
	<td colspan="2" style="font-size:10px"><?php print LANG_073; ?></td>
</tr>
</table>
<br />
<input type="submit" value="<?php print LANG_074; ?>" name="submit" class="form_button" />
</form>

<?php
include(PUNG_ROOT . '/admin/footer.php');
?>